System.register(["@angular/http", "@angular/core", "@angular/router"], function (exports_1, context_1) {
    "use strict";
    var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
        var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
        if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
        else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
        return c > 3 && r && Object.defineProperty(target, key, r), r;
    };
    var __metadata = (this && this.__metadata) || function (k, v) {
        if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
    };
    var __moduleName = context_1 && context_1.id;
    var http_1, core_1, router_1, BoxShipComp;
    return {
        setters: [
            function (http_1_1) {
                http_1 = http_1_1;
            },
            function (core_1_1) {
                core_1 = core_1_1;
            },
            function (router_1_1) {
                router_1 = router_1_1;
            }
        ],
        execute: function () {
            BoxShipComp = (function () {
                function BoxShipComp(http, router) {
                    var _this = this;
                    this.http = http;
                    this.shipConfig = {
                        "underlineOrder": {
                            "is_open": false,
                            "after_time": 0,
                            "interval_time": 0
                        },
                        "startingFare": {
                            "cost": 0
                        },
                        "shipFee": {
                            "cost": 0,
                            "all_order": "0",
                            "full_cost": 0
                        }
                    };
                    router.parent.params.subscribe(function (params) {
                        _this.boxId = params.id;
                        http.get({
                            search: {
                                m: "Admin",
                                c: "ApiBox",
                                a: "getDistribution",
                                box_id: _this.boxId
                            }
                        }).then(function (data) {
                            _this.shipConfig = data.data;
                        });
                    });
                }
                BoxShipComp.prototype.saveUnderLine = function () {
                    var udLine = this.shipConfig.underlineOrder;
                    this.http.post({
                        search: {
                            m: "Admin",
                            c: "ApiBox",
                            a: "setDistribution"
                        },
                        body: {
                            box_id: this.boxId,
                            action: "underlineOrder",
                            json_info: JSON.stringify({
                                is_open: udLine.is_open ? 1 : 0,
                                after_time: udLine.after_time,
                                interval_time: udLine.interval_time
                            })
                        }
                    }).then(function (data) {
                    });
                };
                BoxShipComp.prototype.saveStartingFare = function () {
                    var fare = this.shipConfig.startingFare;
                    this.http.post({
                        search: {
                            m: "Admin",
                            c: "ApiBox",
                            a: "setDistribution"
                        },
                        body: {
                            box_id: this.boxId,
                            action: "startingFare",
                            json_info: JSON.stringify({
                                cost: fare.cost
                            })
                        }
                    }).then(function (data) {
                    });
                };
                BoxShipComp.prototype.saveShipFee = function () {
                    var shipFee = this.shipConfig.shipFee;
                    this.http.post({
                        search: {
                            m: "Admin",
                            c: "ApiBox",
                            a: "setDistribution"
                        },
                        body: {
                            box_id: this.param.id,
                            action: "shipFee",
                            json_info: JSON.stringify({
                                cost: shipFee.cost,
                                all_order: shipFee.all_order ? 1 : 0,
                                full_cost: shipFee.full_cost
                            })
                        }
                    }).then(function (data) {
                    });
                };
                return BoxShipComp;
            }());
            BoxShipComp = __decorate([
                core_1.Component({
                    selector: '.box_ship',
                    templateUrl: 'template/router/boxSetting/ship.html'
                }),
                __metadata("design:paramtypes", [http_1.Http, router_1.ActivatedRoute])
            ], BoxShipComp);
            exports_1("BoxShipComp", BoxShipComp);
        }
    };
});
